package com.mtt.thirdapi.test.controller;

import com.mtt.thirdapi.test.pojo.User;
import com.mtt.thirdapi.test.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @author: Z_Shuan
 */
@RestController
public class UserController {

    @Autowired
    UserService userService;

    /**
     * 查询列表
     * @return
     */
    @GetMapping(value = {"/index",""})
    public List<User> list(){
        List<User> list = this.userService.list();
        return list;
    }

    @PostMapping("submit")
    public Boolean add(User user){
        return this.userService.saveOrUpdate(user);
    }

    @DeleteMapping("delete")
    public Boolean delete(Integer id){
        return this.userService.removeById(id);
    }

}
